<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>IDEA搭建SpringMVC并用maven配置的小例子</title>

    <script type="text/javascript" src="../plugs/js/jquery-1.7.2.js"></script>
</head>
<%--<link rel="stylesheet" href="/asset/css/style.css"/>--%>


<body>
<form id="userForm" action="../user/find" method="post">
    用户名：<input type="text"   name="username"><br>
    密码：<input type="password" name="password"><br>
    <button type="button" onclick="login()">登录</button>
</form>


<script type="text/javascript">

    function login() {

        $.ajax({
            type: 'post',
            url: $('#userForm').attr('action'),
            data: $('#userForm').serialize(),
            dataType: 'json',
            success: function (data) {
                if (data.result == "success") {
                    alert("登录成功");
                    location.href = '../user/success';
                } else {
                    alert("用户名或者密码错误！");
                }
            }
        });
    }

</script>


</body>

</html>
